Skip to content

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Jul 2, 2025

This PR is more a toy than anything else, but I still think the implementation is sound.

Current GVN MIR opt can be easily extended to track values that change inside a basic block. This PR attempts that.

r? @ghost for perf

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 2, 2025
@rust-log-analyzer

This comment has been minimized.

@cjgillot cjgillot force-pushed the local-value-numbering branch from c7dac45 to 62766e3 Compare July 2, 2025 22:11
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@cjgillot cjgillot added the A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) label Jul 5, 2025
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 5, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 5, 2025
bors added a commit that referenced this pull request Jul 5, 2025
[TOY] Extend GVN to perform local value numbering.

This PR is more a toy than anything else, but I still think the implementation is sound.

Current GVN MIR opt can be easily extended to track values that change inside a basic block. This PR attempts that.

r? `@ghost` for perf
@bors
Copy link
Collaborator

bors commented Jul 5, 2025

⌛ Trying commit c3be10b with merge faceb52...

@bors
Copy link
Collaborator

bors commented Jul 5, 2025

☀️ Try build successful - checks-actions
Build commit: faceb52 (faceb52e72c06f94883ba351a73c83544ab4154b)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (faceb52): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
15.4% [0.2%, 937.4%] 227
Regressions ❌
(secondary)
10.3% [0.2%, 569.6%] 237
Improvements ✅
(primary)
-1.1% [-1.8%, -0.4%] 2
Improvements ✅
(secondary)
-1.3% [-4.1%, -0.3%] 16
All ❌✅ (primary) 15.3% [-1.8%, 937.4%] 229

Max RSS (memory usage)

Results (primary 9.1%, secondary 2.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
71.9% [1.6%, 377.4%] 14
Regressions ❌
(secondary)
28.4% [2.2%, 134.5%] 15
Improvements ✅
(primary)
-2.0% [-7.5%, -0.7%] 79
Improvements ✅
(secondary)
-2.5% [-3.5%, -0.8%] 80
All ❌✅ (primary) 9.1% [-7.5%, 377.4%] 93

Cycles

Results (primary 44.8%, secondary 29.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
46.5% [2.3%, 299.4%] 27
Regressions ❌
(secondary)
40.6% [2.4%, 263.2%] 28
Improvements ✅
(primary)
-2.1% [-2.1%, -2.1%] 1
Improvements ✅
(secondary)
-4.2% [-6.7%, -2.4%] 9
All ❌✅ (primary) 44.8% [-2.1%, 299.4%] 28

Binary size

Results (primary -0.1%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.2% [0.0%, 0.6%] 37
Regressions ❌
(secondary)
0.5% [0.0%, 1.7%] 70
Improvements ✅
(primary)
-0.3% [-1.3%, -0.0%] 54
Improvements ✅
(secondary)
-1.0% [-12.8%, -0.0%] 24
All ❌✅ (primary) -0.1% [-1.3%, 0.6%] 91

Bootstrap: 458.797s -> 582.037s (26.86%)
Artifact size: 372.11 MiB -> 361.76 MiB (-2.78%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 5, 2025
@cjgillot cjgillot force-pushed the local-value-numbering branch from c3be10b to e521268 Compare July 6, 2025 08:54
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 6, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 6, 2025
bors added a commit that referenced this pull request Jul 6, 2025
[TOY] Extend GVN to perform local value numbering.

This PR is more a toy than anything else, but I still think the implementation is sound.

Current GVN MIR opt can be easily extended to track values that change inside a basic block. This PR attempts that.

r? `@ghost` for perf
@bors
Copy link
Collaborator

bors commented Jul 6, 2025

⌛ Trying commit e521268 with merge dc4aa90...

@cjgillot cjgillot force-pushed the local-value-numbering branch from e521268 to 0293254 Compare July 6, 2025 08:55
@cjgillot
Copy link
Contributor Author

cjgillot commented Jul 6, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

bors added a commit that referenced this pull request Jul 6, 2025
[TOY] Extend GVN to perform local value numbering.

This PR is more a toy than anything else, but I still think the implementation is sound.

Current GVN MIR opt can be easily extended to track values that change inside a basic block. This PR attempts that.

r? `@ghost` for perf
@bors
Copy link
Collaborator

bors commented Jul 6, 2025

⌛ Trying commit 0293254 with merge 4d16c54...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 6, 2025

☀️ Try build successful - checks-actions
Build commit: 4d16c54 (4d16c544e50b0f84cc5347467c108e93106aa8f9)

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Aug 24, 2025

☀️ Try build successful (CI)
Build commit: 1e45fee (1e45fee2f5452acaa981b7784932fd35cce6349e, parent: c5a6a7bdd89f099544fa0d3fad4d833d238377ad)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1e45fee): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
3.2% [0.5%, 12.8%] 17
Regressions ❌
(secondary)
3.4% [0.3%, 11.6%] 15
Improvements ✅
(primary)
-0.5% [-0.5%, -0.4%] 2
Improvements ✅
(secondary)
-0.5% [-1.1%, -0.2%] 14
All ❌✅ (primary) 2.8% [-0.5%, 12.8%] 19

Max RSS (memory usage)

Results (primary 58.2%, secondary 55.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
69.5% [1.8%, 288.2%] 11
Regressions ❌
(secondary)
55.7% [2.2%, 150.0%] 7
Improvements ✅
(primary)
-4.1% [-5.4%, -2.9%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 58.2% [-5.4%, 288.2%] 13

Cycles

Results (primary 5.4%, secondary 11.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
5.4% [2.1%, 12.7%] 7
Regressions ❌
(secondary)
11.6% [2.3%, 17.1%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.4% [2.1%, 12.7%] 7

Binary size

Results (primary -0.1%, secondary -1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.3% [0.1%, 0.4%] 6
Regressions ❌
(secondary)
0.4% [0.1%, 1.0%] 4
Improvements ✅
(primary)
-0.1% [-1.1%, -0.0%] 34
Improvements ✅
(secondary)
-1.6% [-12.8%, -0.0%] 9
All ❌✅ (primary) -0.1% [-1.1%, 0.4%] 40

Bootstrap: 467.196s -> 479.382s (2.61%)
Artifact size: 378.17 MiB -> 378.25 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 24, 2025
@bors
Copy link
Collaborator

bors commented Aug 27, 2025

☔ The latest upstream changes (presumably #145923) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Aug 27, 2025
@cjgillot cjgillot force-pushed the local-value-numbering branch from 290a3bc to e4e6897 Compare September 6, 2025 21:06
@cjgillot
Copy link
Contributor Author

cjgillot commented Sep 6, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Sep 6, 2025
[TOY] Extend GVN to perform local value numbering.
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 6, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Sep 6, 2025

☀️ Try build successful (CI)
Build commit: e1059c0 (e1059c093c9366f7d49459a4527c600a458553d2, parent: bea625f3275e3c897dc965ed97a1d19ef7831f01)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e1059c0): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
1.0% [0.1%, 5.0%] 30
Regressions ❌
(secondary)
1.2% [0.2%, 6.6%] 25
Improvements ✅
(primary)
-0.3% [-0.6%, -0.2%] 8
Improvements ✅
(secondary)
-0.7% [-2.9%, -0.1%] 38
All ❌✅ (primary) 0.7% [-0.6%, 5.0%] 38

Max RSS (memory usage)

Results (primary 2.1%, secondary 4.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.6% [1.4%, 5.6%] 7
Regressions ❌
(secondary)
4.0% [4.0%, 4.0%] 1
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.1% [-1.4%, 5.6%] 8

Cycles

Results (secondary -0.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.1% [-2.3%, -2.0%] 2
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.1%, secondary -0.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.1%] 10
Regressions ❌
(secondary)
0.0% [0.0%, 0.5%] 26
Improvements ✅
(primary)
-0.1% [-2.0%, -0.0%] 57
Improvements ✅
(secondary)
-1.4% [-12.8%, -0.0%] 11
All ❌✅ (primary) -0.1% [-2.0%, 0.1%] 67

Bootstrap: 468.001s -> 466.665s (-0.29%)
Artifact size: 387.44 MiB -> 387.54 MiB (0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 7, 2025
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 8, 2025

☔ The latest upstream changes (presumably #146304) made this pull request unmergeable. Please resolve the merge conflicts.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 8, 2025
GVN: Ensure indirect is first projection in try_as_place.

I haven't found any report for this bug on existing code, but managed to trigger it with rust-lang#143333
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 8, 2025
GVN: Ensure indirect is first projection in try_as_place.

I haven't found any report for this bug on existing code, but managed to trigger it with rust-lang#143333
rust-timer added a commit that referenced this pull request Sep 8, 2025
Rollup merge of #146298 - cjgillot:gvn-derefer, r=nnethercote

GVN: Ensure indirect is first projection in try_as_place.

I haven't found any report for this bug on existing code, but managed to trigger it with #143333
@cjgillot cjgillot force-pushed the local-value-numbering branch from 581eba0 to 48bb7ae Compare September 9, 2025 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants